package com.mtiiot;

import com.mtiiot.server.netty.NettyServer;

//import com.mtiiot.boxnettyserver.thread.ServerHeartThread;
import com.mtiiot.util.Constants;
import org.apache.log4j.PropertyConfigurator;

import java.io.FileInputStream;
import java.util.Properties;

public class BootStrap {
	//private static Logger logger = LogManager.getLogger(BootStrap.class);
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if(args!=null&&args.length>0){
			try {
				//Constants.port=Integer.parseInt(args[0]);
                Constants.configPath=args[0];
			} catch (Exception e) {
                e.printStackTrace();
				//logger.error("Exception info:"+e.getMessage());
				return;
			}
		}else{
            System.out.println("Exception info:"+"input args error!! ");
			//logger.error("Exception info:"+"input args error!! ");
			return;
		}
		try {
            //初始化log4j路径
            Properties pps = new Properties();
            pps.load(new FileInputStream(Constants.configPath));
            String logPath=pps.getProperty("logConfigPath");
            PropertyConfigurator.configure(logPath);
            Constants.init();//初始化相关
            //new ServerHeartThread().start();//每隔一段时间往服务器发送心跳信息
            NettyServer ns = new NettyServer();
			ns.bing(Constants.config.getServerPort());
		} catch (Exception e) {
            e.printStackTrace();
			//logger.error("Exception trace:"+e.getMessage());
		}
	}
}
